package cn.lotusnut.dynamicscheduled.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author JiangMing Zhou
 * @date 2023/9/8 14:31
 * @jdk 1.8
 */
public class TestUtils {
    public static String[] getWord(String str) {
        int wordStartIndex = getWordStartIndex(str);
        return new String[]{str.substring(0,wordStartIndex),str.substring(wordStartIndex)};
    }

    public static boolean checkcountname(String countname)
    {
        Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
        Matcher m = p.matcher(countname);
        if (m.find()) {
            return true;
        }
        return false;
    }

    public static int getWordStartIndex(String str) {
        int index = 0;
        for (char c : str.toCharArray()) {
            if (!Character.isDigit(c)) {
                break;
            }
            index++;
        }
        return index;
    }

    public static int getEndIndex(String Str)
    {
        int n = 0;
        for(int i = 0; i < Str.length(); i++) {
            n = (int)Str.charAt(i);
            if(!(19968 <= n && n <40869)) {
                return i;
            }
        }
        return -1;
    }

    public static boolean isNumeric4(String str) {
        return str != null && str.chars().allMatch(Character::isDigit);
    }

}
